package com.airlines.crewassignment.service.basicinfo.impl;

import com.airlines.common.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.airlines.crewassignment.service.basicinfo.CodeService;
import com.airlines.crewassignment.entity.basicinfo.Code;
import java.util.List;
import com.airlines.crewassignment.dao.basicinfo.CodeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * @author xxxx
 * @date 2018/05/23 11:09:31
 * @company xxxx Airlines
 * @description 
 */
@Service
public class CodeServiceImpl implements CodeService {

    @Autowired
    private CodeMapper codeMapper;

    @Override
    public int insert(Code code){
        return codeMapper.insert(code);
    }

    @Override
    public int delete(String parentCode,String cCode,String moduleFlag){
        return codeMapper.delete(parentCode,cCode,moduleFlag);
    }


    @Override
    public int update(Code code){
        return codeMapper.update(code);
    }

    @Override
    public Code get(String parentCode,String cCode,String moduleFlag){
        return codeMapper.get(parentCode,cCode,moduleFlag);
    }

    @Override
    public List<Code> list(Code code){
        return codeMapper.list(code);
    }

    @Override
    public Page list(Code code, Page page){
        PageHelper.startPage(page.getPageNumber(), page.getPageSize());
        List<Code> list = codeMapper.listByFuzzy(code);
        PageInfo<Code> pageInfo = new PageInfo<Code>(list);
        page.setTotal(String.valueOf(pageInfo.getTotal()));
        page.setRows(pageInfo.getList());
        return page;
    }




}
